package com.benchmark.springboot.concurrent;

import java.util.concurrent.Callable;

import com.benchmark.springboot.service.UserService;
import com.benchmark.springboot.utils.SpringBeanUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * callable中不能直接注入，采用BeanUtil获取
 * @author yu3.sun on 2022/6/24
 */
@Slf4j
public class MyCallable implements Callable<String> {

  private UserService userService;

  public MyCallable(){
    this.userService = SpringBeanUtil.getBean(UserService.class);
  }

  @Override
  public String call() {
    log.info("invoked callable query user,User={}",userService.queryById(0));
    return null;
  }
}
